/*
 * Copyright (c) 2022 Oracle and/or its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.helidon.messaging;

import java.util.concurrent.CompletionStage;
import java.util.function.Function;

import org.eclipse.microprofile.reactive.messaging.Message;

/**
 * Nack handler for interface for messages connectors.
 *
 * @param <M> Connector specific message type
 */
public interface NackHandler<M extends Message<?>> {

    /**
     * Error type causing the message to be sent to DLQ.
     */
    String DLQ_ERROR_PROP = "dlq-error";
    /**
     * Message from error causing DLQ redirection.
     */
    String DLQ_ERROR_MSG_PROP = "dlq-error-msg";
    /**
     * Original destination of this message.
     */
    String DLQ_ORIG_TOPIC_PROP = "dlq-orig-destination";

    /**
     * Return nack function to be used by message when nacked.
     *
     * @param message owner message of the nack function
     * @return nack function to be used by message when nacked
     */
    Function<Throwable, CompletionStage<Void>> getNack(M message);
}
